#coding=utf-8

class Move(object):
    u'''方块的移动走法对象 '''

    def __init__(self, src, dst, mask=0):
        self.src = src
        self.dst = dst
        self.mask = mask
        if mask == 0:
            self.mask = (dst.mask | src.mask) ^ src.mask
        self._nexts = None

    @property
    def nexts(self):
        u'''方块的连续移动走法 '''
        if self._nexts is None:
            self._nexts = []
            masks = [1 << i for i in range(20)]
            if self.mask in masks:
                for move in self.dst.moves:
                    if move.mask in masks and move.dst is not self.src:
                        move = Move(self.src, move.dst, self.mask | move.mask)
                        self._nexts.append(move)
        return self._nexts

    def __eq__(self, other):
        return self.src == other.src and self.dst == other.dst

    def __str__(self):
        return '%s to %s' % (self.src, self.dst)
    __repr__ = __str__
